package com.xysd.express.activity.mine.setting;

import android.view.View;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xysd.express.R;
import com.xysd.express.base.BaseActivity;
import com.xysd.express.util.DataCleanManager;
import com.xysd.express.util.ToastUtil;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

@ContentView(R.layout.activity_common_setting)
public class CommonSettingActivity extends BaseActivity implements View.OnClickListener {

    @ViewInject(R.id.push_onoff)
    private CheckedTextView push_onoff;
    @ViewInject(R.id.charge_layout)
    private LinearLayout charge_layout;
    @ViewInject(R.id.rules_layout)
    private LinearLayout rules_layout;
    @ViewInject(R.id.share_layout)
    private LinearLayout share_layout;
    @ViewInject(R.id.release_layout)
    private LinearLayout release_layout;
    @ViewInject(R.id.cache_tv)
    private TextView cache_tv;



    @Override
    protected void init() {
        setTitleBar("通用");
        push_onoff.setOnClickListener(this);
        charge_layout.setOnClickListener(this);
        rules_layout.setOnClickListener(this);
        share_layout.setOnClickListener(this);
        release_layout.setOnClickListener(this);

        try {
//            cache_tv.setText(DataCleanManager.getCacheSize(getCacheDir()));
            cache_tv.setText(DataCleanManager.getCacheSize(getExternalCacheDir()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.push_onoff:
                push_onoff.toggle();
                break;
            case R.id.charge_layout:
                ToastUtil.show("升级中");
                break;
            case R.id.rules_layout:
                ToastUtil.show("升级中");
                break;
            case R.id.share_layout:
                ToastUtil.show("升级中");
                break;
            case R.id.release_layout:
//                DataCleanManager.cleanInternalCache(mActivity);
                DataCleanManager.cleanExternalCache(mActivity);
                ToastUtil.show("清理成功");
                cache_tv.setText("0.0MB");
                break;
        }
    }
}
